package com.example.myapplication.kotlin

fun main() {
 //数字数组 0-5
    val numbers = arrayOf(0,1,2,3,4,5)
    //用map 进行映射，每个数组翻 2倍
    val numbers2 = numbers.map( {num: Int->num *2})
    println(numbers2)
    //当只有 一个参数时 可以用it 代替
    val numbers3 = numbers.map { it * 2 }
    println(numbers3)
    //筛选 大于 4 的数字
    val numbers4 = numbers.filter { it > 4 }
    val numbers5 = numbers.filter { num: Int->num > 4 }
    println(numbers4)
    println(numbers5)
    val numbers6 = calculate(15000,0.8,{a,b->a*b})
    println(numbers6)
}
fun calculate(a:Int,b: Double,operation:(Int,Double)->Double):Double{
    return  operation(a,b)
}